package org.afs.gescol.component.edt.gwt.server.service.mock;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.bradrydzewski.gwt.calendar.client.Appointment;
import com.bradrydzewski.gwt.calendar.client.AppointmentStyle;

public class GetServicesMock {
    public static final AppointmentStyle[] ICAL_STYLES =
            new AppointmentStyle[]{AppointmentStyle.BLUE, AppointmentStyle.RED, AppointmentStyle.PINK,
        AppointmentStyle.PURPLE, AppointmentStyle.DARK_PURPLE, AppointmentStyle.STEELE_BLUE,
        AppointmentStyle.LIGHT_BLUE, AppointmentStyle.TEAL, AppointmentStyle.LIGHT_TEAL,
        AppointmentStyle.GREEN, AppointmentStyle.LIGHT_GREEN, AppointmentStyle.YELLOW_GREEN,
        AppointmentStyle.YELLOW, AppointmentStyle.ORANGE, AppointmentStyle.RED_ORANGE,
        AppointmentStyle.LIGHT_BROWN, AppointmentStyle.LIGHT_PURPLE, AppointmentStyle.GREY,
        AppointmentStyle.BLUE_GREY, AppointmentStyle.YELLOW_GREY, AppointmentStyle.BROWN};

    public static final String[] MATIERES =
            new String[]{"Français", "Anglais", "SVT", "Histo-Géo", "Maths", "Sces. Physiques",
        "EPS", "Dessin", "Musique", "Philo.", "Allemand", "Informatique"
//        ,AppointmentStyle.YELLOW, AppointmentStyle.ORANGE, AppointmentStyle.RED_ORANGE,
//        AppointmentStyle.LIGHT_BROWN, AppointmentStyle.LIGHT_PURPLE, AppointmentStyle.GREY,
//        AppointmentStyle.BLUE_GREY, AppointmentStyle.YELLOW_GREY, AppointmentStyle.BROWN
        };

    public static final String[] PROFS =
            new String[]{"M. SOGBO Kokou", "M. MESSAN Dela", "M. ADJE Kodjo", "Mme HOFFER Lys", "M. GBENYO Kobla", "M. GBENYO Koffi",
        "M. FOLIKOUE Kossi", "Mme AHOVI Serafin", "M. LAWSON Adjé", "M. TEKA Alain", "Mme KPADENOU Joelle", "M. SENAH Têtê"};

    public static final Integer[][] DURATIONS =
            new Integer[][]{
        {120, 0, 0, 60, 120, 0, 0, 0, 0, 0, 120, 0},
        {0, 120, 60, 0, 120, 120, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 180, 0, 0, 0, 120, 120, 0, 0},
        {55, 0, 120, 0, 0, 120, 120, 0, 0, 0, 0, 0},
        {60, 60, 60, 120, 0, 0, 0, 60, 0, 0, 0, 60}};

    public static final Integer[][] HEURES_DEB =
            new Integer[][]{
        {6, 0, 0, 8, 10, 0, 0, 0, 0, 0, 15, 0},
        {0, 6, 8, 0, 10, 15, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 6, 0, 0, 0, 10, 15, 0, 0},
        {6, 0, 7, 0, 0, 10, 15, 0, 0, 0, 0, 0},
        {6, 7, 8, 10, 0, 0, 0, 15, 0, 0, 0, 16}};

    public static final Integer[][] MINUTES_DEB =
            new Integer[][]{
        {45, 0, 0, 45, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 45, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {0, 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, 0},
        {45, 0, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0},
        {45, 45, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0}};

    public static List<Appointment> getEdtContents(Date aux) {
        final List<Appointment> res = new ArrayList<Appointment>();
        aux.setSeconds(0);
        aux.setDate(aux.getDate());
        for (int i = 0; i < 5; i++) {
            int durAux = 0;
            for (int j = 0; j < 12; j++) {
                int dur = DURATIONS[i][j];
                if (dur > 0) {
                    int hour = HEURES_DEB[i][j];
                    int min = MINUTES_DEB[i][j];
                    Date start = (Date) aux.clone();
                    start.setHours(hour);
                    start.setMinutes(min);
                    Date end = (Date) start.clone();
                    end.setMinutes(start.getMinutes() + dur);
                    Appointment appt = new Appointment();
                    appt.setStart(start);
                    appt.setEnd(end);
                    appt.setTitle(MATIERES[j]);
                    appt.setDescription(PROFS[j]);
                    appt.setStyle(ICAL_STYLES[j]);
                    res.add(appt);
                }
            }
            aux.setDate(aux.getDate() + 1);
            aux.setHours(7);
            aux.setMinutes(0);
        }
        return res;
    }

}
